home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12539 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.9 KB  |  61 lines

  1. Newsgroups: comp.lang.c
  2. Path: netcom.com!andrewr
  3. From: andrewr@netcom.com (Andrew Reddig)
  4. Subject: Re: Borland C's tmpnam()
  5. Message-ID: <andrewrDp62z2.uw@netcom.com>
  6. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  7. X-Newsreader: TIN [version 1.2 PL1]
  8. References: <AD75E5DC9668E2A52@mcdiala13.it.luc.edu> <Pine.A32.3.91.960322134158.23347A-100000@red.weeg.uiowa.edu> <AD78E5E796681EC58@mcdialb10.it.luc.edu> <827626790snz@genesis.demon.co.uk> <AD7CDFD39668AABD2@mcdiala01.it.luc.edu> <828276946snz@genesis.demon.co.uk> <AD84A73496681719A2@mcdiala03.it.luc.edu>
  9. Date: Mon, 1 Apr 1996 04:54:38 GMT
  10. Sender: andrewr@netcom13.netcom.com
  11.  
  12. Verne Arase (VArase@varase.it.luc.edu) wrote:
  13. : In article <828276946snz@genesis.demon.co.uk>,
  14. : Lawrence Kirby <fred@genesis.demon.co.uk> wrote:
  15.  
  16. :  >>If you're stating that tmpnam() under Borland C does indeed check to see
  17. :  >>that the file name is unique, I'll quash that reluctance and change the
  18. :  >>default directory.
  19. :  >
  20. :  >I don't know what Borland C actually does. It it is a conforming
  21. :  >implementation it must ensure that the name it generates is valid and
  22. :  >doesn't already exist in the filesystem.
  23.  
  24. : Actually, it doesn't.
  25.  
  26. : All it does it insure that the file name doesn't exist in the current
  27. : location in the file system. Which, I'd imagine, is what just about every
  28. : implementation does.
  29.  
  30. : It's be a lot more useful if you could specify a target directory, though
  31. : the string that makes up that specification would be target environment
  32. : dependant.
  33.  
  34. I don't have the ANSI spec handy, but given that ANSI doesn't guarantee
  35. much about directories, drives, etc., it would seem logical that a
  36. conforming implementation is required to return whatever magic name is
  37. both (a) a valid filename and (b) not an existing file based on the
  38. current program context.  Absent the race condition already discussed,
  39. what you need to do with the filename is open it - ANSI is pretty much
  40. silent on doing anything else with the filename, right?  Once you open it,
  41. you can then change directories/drives/etc and the handle still points at
  42. a temporary file (which is what you want). 
  43.  
  44. So, Borland could return an 8.3 filename, "C:\TEMP\BORLAND.001", or 
  45. whatever as long as you can open the file and not collide with an 
  46. existing file.  What you get by looking at the filename is undefined.
  47.  
  48. If the standard is silent on where the temporary file is located, a
  49. conforming program couldn't change directories and assume that the file is
  50. put in that directory anyway; a conforming implementation could 
  51. automagically put all temporary files in /tmp. 
  52.  
  53. --- Andy R. (andrewr@netcom.com)
  54.  
  55. -- 
  56. --------------------------------------------------------------------
  57. Andrew Reddig                          #include "usual.disclaimer.h"
  58. TEK Microsystems, Incorporated             Email: andyr@tekmicro.com
  59. One North Avenue                           Telephone: (617) 270-0808
  60. Burlington, MA  01803                            Fax: (617) 270-0813
  61.